package servlet;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.*;
import model.Goods;
import org.apache.commons.beanutils.BeanUtils;
import service.GoodsService;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

@WebServlet(name="UpdateGoodsServlet",value = "/UpdateGoodsServlet")

public class UpdateGoodsServlet extends HttpServlet {
    private GoodsService goodsService=new GoodsService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Goods goods=new Goods();
        try {
            BeanUtils.copyProperties(goods,request.getParameterMap());
        } catch (Exception e) {
            e.printStackTrace();
        }
        goodsService.updateUser(goods);
        request.getRequestDispatcher("userlistAdmin.jsp").forward(request, response);
        System.out.println(goods + "====");

    }
}
